<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>forget</title>
    <h1 onclick="autoChange();">切换图片</h1>
    <h1 onclick="stopChange();">停止切换</h1>
</head>
<body>
<img src="/picture/1/00001.jpg" id="myimg">
</body>
</html>
<script type="text/javascript">
    var i = 00001;
    var n;
    function changeImg() {
        var bigimg = document.getElementById("myimg");
        bigimg.src="/picture/1/" + pad(i++,5) +".jpg" ;
    }
    function pad(num, n) {
        var len = num.toString().length;
        while(len < n) {
            num = "0" + num;
            len++;
        }
        return num;
    }
    function autoChange() {
        n=window.clearInterval(n);
        i = 00001;
        n=setInterval(function () {
            changeImg();
        }, 200);
    }
    function stopChange() {
        window.clearInterval(n);
    }
</script>